<template>
  <div>
    <div class="mui-numbox" data-numbox-min='1'>						
			<button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
			<input id="test" class="mui-input-numbox" @change="numchange" ref="poxnum" type="number" value="" />
			<button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
		</div>
  </div>
</template>

<script>

import mui from '../../lib/mui/js/mui.min.js'

import { Toast } from 'mint-ui';

export default {
  mounted() {
    mui('.mui-numbox').numbox();
  },
  methods: {
    numchange() {
      if(this.$refs.poxnum.value > this.maxNum) {
        Toast('购买数量超出限制，请从新选择!');
        return ;
      }
			this.$emit('getnumcount', parseInt(this.$refs.poxnum.value));
		}
  },
  props: ['maxNum'],
  watch: {
    maxNum: function (newVal) {

      //设置numbox最大值
      mui(".mui-numbox").numbox().setOption("max", newVal);
    }
  }
};
</script>

<style>
</style>
